// DVBDialog.cpp : implementation file
//

#include "stdafx.h"
#include "TSG.h"
#include "DVBDialog.h"


// CDVBDialog dialog

IMPLEMENT_DYNAMIC(CDVBDialog, CDialog)

CDVBDialog::CDVBDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CDVBDialog::IDD, pParent)
{

}

CDVBDialog::~CDVBDialog()
{
}

void CDVBDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_RULE_TYPE, m_TabCtrl);
}


BEGIN_MESSAGE_MAP(CDVBDialog, CDialog)
	ON_NOTIFY(TCN_SELCHANGE, IDC_RULE_TYPE, &CDVBDialog::OnTcnSelchangeRuleType)
END_MESSAGE_MAP()


// CDVBDialog message handlers


BOOL CDVBDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	m_TabCtrl.InsertItem(0, _T("DVB Table"));
	m_TabCtrl.InsertItem(1, _T("DVB Descriptor"));

	m_DVBTableDlg.Create(IDD_DVB_TABLE, GetDlgItem(IDC_RULE_TYPE));
	m_DVBDescDlg.Create(IDD_DVB_DESC, GetDlgItem(IDC_RULE_TYPE));

	CRect rc;
	m_TabCtrl.GetClientRect(&rc);
	rc.top += 22;
	rc.bottom -= 3;
	rc.left += 3;
	rc.right -= 3;
	m_DVBTableDlg.MoveWindow(rc);
	m_DVBDescDlg.MoveWindow(rc);
	m_TabCtrl.SetCurSel(0);
	m_DVBTableDlg.ShowWindow(TRUE);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CDVBDialog::OnTcnSelchangeRuleType(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: Add your control notification handler code here
	int nCursel = m_TabCtrl.GetCurSel();
	switch(nCursel)
	{
	case 0:
		m_DVBTableDlg.ShowWindow(TRUE);
		m_DVBDescDlg.ShowWindow(FALSE);
		break;
	case 1:
		m_DVBTableDlg.ShowWindow(FALSE);
		m_DVBDescDlg.ShowWindow(TRUE);
	default:
		break;
	}

	*pResult = 0;
}
